<template>
  <div class="app-container">
    <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" :filters="filters" />
  </div>
</template>
<script>
import WiseCrud from '@/components/Crud/wiseCrud'
import { imgPath } from '../../../../filters'
export default {
  name: 'AlarmPeople',
  components: { WiseCrud },
  data() {
    return {
      urls: {
        list: '/api/v1/welder-sbtx-second/hj-member',
        add: '/api/v1/welder-sbtx-second/hj-member-comb/create',
        show: '/api/v1/welder-sbtx-second/hj-member/show/',
        update: '/api/v1/welder-sbtx-second/hj-member/update/',
        delete: '/api/v1/welder-sbtx-second/hj-member/remove/'
      }
    }
  },
  computed: {
    spaceId() {
      return this.$store.state.project.spaceId
    },
    handle() {
      // if (this.$store.state.user.project) {
      //   return ['add']
      // } else {
      //   return ['add', 'filters']
      // }
      return ['add']
    },
    fields() {
      let arr = [
        { label: '序号', type: 'index', use: ['table'] }
      ]
      if (this.$store.state.user.project) {
        arr.push({
          prop: 'projectId',
          defaultValue: this.$store.state.user.project.id,
          use: ['add', 'edit']
        })
      }
      // arr.push({
      //   label: '所属项目',
      //   prop: 'projectInfo',
      //   type: 'select',
      //   labelWidth: '130px',
      //   url: '/api/v1/welder-sbtx-second/project-info',
      //   labelKey: 'name',
      //   valueKey: 'id',
      //   objKeys: [
      //     {
      //       field: 'projectId',
      //       key: 'id'
      //     }
      //   ],
      //   rules: [
      //     { required: true, message: '请选择项目', trigger: 'change' }
      //   ],
      //   placeholder: '请选择项目',
      //   use: ['add', 'edit', 'filters']
      // })
      // arr.push({
      //   label: '所属项目',
      //   prop: 'manage',
      //   type: 'render',
      //   labelWidth: '130px',
      //   tableRender: (h, row, index) => {
      //     return h('div', row.projectInfo ? row.projectInfo.name : '')
      //   },
      //   viewRender: (h, item, object) => {
      //     return h('div', object.projectInfo ? object.projectInfo.name : '')
      //   },
      //   use: ['table', 'view']
      // })
      arr.push(
        {
          label: '现场总人数',
          prop: 'headCount',
          type: 'number',
          labelWidth: '130px',
          rules: [
            { required: true, message: '请输入现场总人数', trigger: 'change' }
          ],
          placeholder: '请输入现场总人数',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          prop: 'spaceId',
          defaultValue: this.$store.state.project.spaceId,
          use: ['add', 'edit']
        }
      )
      arr.push({ label: '操作', type: 'handle', use: ['table'], handle: ['edit', 'view', 'delete'], tableWidth: 300 })
      return arr
    },
    filters() {
      return [{
        field: 'spaceId',
        operator: 'EQUALS',
        value: this.$store.state.project.spaceId
      }]
    }
  },
  methods: {
  }
}
</script>

<style>

</style>
